#ifndef CVCACHEMANAGER_H
#define CVCACHEMANAGER_H

#include <QObject>
#include <QApplication>
#include <QUrl>
#include <QFile>
#include <QHash>
#include <QDir>
#include <QFileInfo>
#include <QFileInfoList>
#include <QCryptographicHash>
#include <QByteArray>
#include <QTextCodec>
#include <QImage>

#include "cvsession.h"
#include "model/cvnetwork.h"

class CVImageCache : public QObject
{
    Q_OBJECT
public:
    enum FILE_TYPE {       
        TYPE_PNG = 0,
        TYPE_JPG = 1,
        TYPE_GIF = 2,
        TYPE_NONE = -1
    };

    virtual ~CVImageCache();
    static CVImageCache *instance();
    
    QImage get(QUrl url);
    void add(QUrl url, QImage image, FILE_TYPE type = TYPE_PNG);
    bool contains(QUrl url);
    void clear(bool includeFiles = false);
signals:
    
public slots:
private:
    CVImageCache();
    void init();
    QString getCachePath();
    QString md5Path(QUrl url);

    class Private;
    Private *const d;
    static CVImageCache *staticObject;

    CVSession *session;
};

#endif // CVCACHEMANAGER_H
